package com.gusti.vlc.controller.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.gusti.vlc.controller.IVlcController;
import com.gusti.vlc.services.IVlcService;
import com.gusti.vlc.util.ConstantsUtil;
import com.gusti.vlc.util.VlcResponse;

/**
 * 
 * @author gusti
 *
 */
@Controller
public class VlcController implements IVlcController {

	@Autowired
	IVlcService vlcService;

	@RequestMapping(value = "/command", method = RequestMethod.GET)
	@ResponseBody
	public VlcResponse executeStatusCommand() {

		return vlcService.executeStatusCommand( null );
	}

	@RequestMapping(value = "/command/{command}", method = RequestMethod.GET)
	@ResponseBody
	public VlcResponse executeStatusCommand( @PathVariable("command") String command ) {
		
		return vlcService.executeStatusCommand( command );
	}

	@RequestMapping(value = "/404", method = RequestMethod.GET)
	@ResponseBody
	public VlcResponse error404() {
		VlcResponse vlcResponse = new VlcResponse();
		vlcResponse.setErrorMsg( ConstantsUtil.ERROR_404 );
		return vlcResponse;
	}

	@RequestMapping(value = "/500", method = RequestMethod.GET)
	@ResponseBody
	public VlcResponse error500() {
		VlcResponse vlcResponse = new VlcResponse();
		vlcResponse.setErrorMsg( ConstantsUtil.ERROR_500 );
		return vlcResponse;
	}

}
